package com.olap.starter.controller.admin.luckycola.utils;

import lombok.Getter;
@Getter
public enum DefaultFieldEn {
    CREATOR("CREATOR", "创建者", SqlUtil.getType("255")),
    UPDATER("UPDATER", "更新者", SqlUtil.getType("255")),
    CREATE_TIME("CREATE_TIME", "创建时间", "SYSDATE", "DATE"),
    UPDATE_TIME("UPDATE_TIME", "修改时间", "SYSDATE", "DATE"),
    ID("ID", "主键", "sys_guid()", SqlUtil.getType("50")),
    REMARK("REMARK", "备注", SqlUtil.getType("255"), " "),
    DELETED("DELETED", "是否删除", "0" ,SqlUtil.getType("1")),
    TENANT_ID("TENANT_ID", "租户编号", "0", SqlUtil.getType("255"));
    String code;
    String desc;
    String value;
    String type;
    String alias;

    DefaultFieldEn(String code, String desc, String type) {
        this.code = code;
        this.desc = desc;
        this.type = type;
    }

    DefaultFieldEn(String code, String desc, String value, String type) {
        this.code = code;
        this.desc = desc;
        this.value = value;
        this.type = type;
    }
    public static String getAlias(String code) {
        if (CREATOR.code.equals(code)) {
            return "CREATE_USER";
        }
        if (UPDATER.code.equals(code)) {
            return "UPDATE_USER";
        }
        return "";
    }
    public static String codeToDesc(String code) {
        for (DefaultFieldEn eventDesc : DefaultFieldEn.values()) {
            if (eventDesc.code.equals(code)) {
                return eventDesc.desc;
            }
        }
        return "";
    }
    public static DefaultFieldEn getByCode(String code) {
        for (DefaultFieldEn en : DefaultFieldEn.values()) {
            if (en.code.equals(code)) {
                return en;
            }
        }
        return null;
    }
}
